package servidor_diseno2011;

import java.io.IOException;
import java.io.InputStream;

import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;


public class SecureServer {

	
	
	public static void main(String args[]){
		
		SSLServerSocketFactory sslSocketFactory= (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
		try {
			//int port = Integer.parseInt(args[1]);
			int port= 8888;
			SSLServerSocket ssl_server= (SSLServerSocket)sslSocketFactory.createServerSocket(port);
			while (true) {
				
				final SSLSocket ssl_socket = (SSLSocket) ssl_server.accept();
				
				Runnable newConnection= new Runnable() {	
					@Override
					public void run() {
						// TODO Auto-generated method stub
						try {
							InputStream input= ssl_socket.getInputStream();
							//Proceso el input stream
							System.out.println("Nueva Coneccion");
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				};
				
				
				Thread thread= new Thread(newConnection);
				thread.start();
			}
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
}
